Let stub-defined __all__ override imports
          #133
        
          
      
                
     Draft
            
            
          
      
        
          +73
        
        
          −1
        
        
          
        
      
    
  
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
In scikit-image, I encountered the case where I want to make certain functions available for lazy-loading while at the same time not wanting to advertise their existence via
__all__(see scikit-image/scikit-image#6892). To implement this with the current behavior oflazy_loader.attach_stubI had to specify__all__twice, both in the PY and in the PYI file (see scikit-image/scikit-image@40157d0).Ideally, I'd like to avoid this duplication. So I came up with a quick "work in progress" solution, in order to discuss this use case here. The current draft has some drawbacks for now, e.g. it makes certain assumptions about how
__all__must be defined in the stub. I'm happy to iterate on this, depending on which kind of behavior is wanted.Please, let me know what you think. 😊